package com.sphd.emanu.activity.integralscore;

import android.content.Context;

import com.google.gson.JsonObject;
import com.sphd.emanu.mvp.BasePresenterImpl;
import com.sphd.emanu.pojo.goods.Commodity;
import com.sphd.emanu.pojo.market.PointsQueryVo;
import com.sphd.emanu.utils.GsonUtil;
import com.wzutils.L;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * MVPPlugin
 *  邮箱 784787081@qq.com
 */

public class IntegralscorePresenter extends BasePresenterImpl<IntegralscoreContract.View> implements IntegralscoreContract.Presenter{

    @Override
    public void selectPoints(Integer org) {
        emanuService.selectPoints(org).enqueue(new Callback<String>() {
            @Override
            public void onResponse(Call<String> call, Response<String> response) {
                L.e(response.toString());
                PointsQueryVo pointsQueryVo= GsonUtil.GsonToBean(response.body(),PointsQueryVo.class);
                mView.recBean(pointsQueryVo);
            }

            @Override
            public void onFailure(Call<String> call, Throwable t) {
            Error(t);
            }
        });
    }

    @Override
    public void updateConfig(Integer id, Integer org, Boolean isPiont) {
            emanuService.updateConfig(id, org, isPiont).enqueue(new Callback<JsonObject>() {
                @Override
                public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
                    mView.recRes(res(response));
                }

                @Override
                public void onFailure(Call<JsonObject> call, Throwable t) {
                    Error(t);
                }
            });
    }


}
